// 导入定义用户名和密码的规则的包
const joi = require("joi");

// 定义用户名和密码的验证规则
const username = joi
  .string()
  .regex(/^[\w]{3,10}$/)
  .required();
const password = joi
  .string()
  .pattern(/^[\S]{6,11}$/)
  .required();

// 定义验证登录数据的规则对象
exports.reg_login_schema = {
  body: {
    username,
    password,
    ip: joi.required(),
    address: joi.required(),
    flag: joi.number(),
  },
};
// 定义验证修改密码的规则对象
exports.reg_updatePwd_schema = {
  body: {
    oldPwd: password,
    newPwd: joi.not(joi.ref("oldPwd")).concat(password),
  },
};
